package com.tanhua.server.controller;

import com.tanhua.model.vo.PageResult;
import com.tanhua.server.service.VideosService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/smallVideos")
public class SmallVideoController {

    @Autowired
    private VideosService videosService;


    /**
     * 分页查询视频列表
     *
     * @param page
     * @param pagesize
     * @return
     */
    @GetMapping
    public ResponseEntity smallVideosPage(@RequestParam(defaultValue = "1") Integer page,
                                         @RequestParam(defaultValue = "1o") Integer pagesize) {

       PageResult result= videosService.findVideos(page,pagesize);
        return ResponseEntity.ok(result);
    }


        /**
         * 发布视频
         * 接口路径：POST
         * 请求参数：
         * videoThumbnail：封面图
         * videoFile：视频文件
         */
        @PostMapping
        public ResponseEntity saveVideos(MultipartFile videoThumbnail, MultipartFile videoFile) throws IOException {
            videosService.saveVideos(videoThumbnail, videoFile);
            return ResponseEntity.ok(null);
        }


}
